package com.ihg.hiex.entity.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.ihg.hiex.entity.session.Session;

/**
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "delegate_coaching_conversation")
public class DelegateCoachingConversation {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 名称 */
    private String name;
    
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date conversationDate;
    
    /** 状态 */
    @Enumerated(EnumType.STRING)
    private ConversationStatus status;
    
    /** theme */
    private String theme;
    
    /** major take-away */
    private String majorTakeAway;
    
    /** next step action plan */
    private String nextActionPlan;
    
    /** attachment */
    private String attachment;
    
    private Date lastUpdateTime;
    
    private Long lastOperator;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Delegate delegate;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Session session;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * 
     */
    public DelegateCoachingConversation() {
        
    }
    
    /**
     * 
     * @param attachment
     * @param session
     * @param delegate
     * @param operator
     * @return
     */
    public DelegateCoachingConversation initilization(String attachment, Session session, Delegate delegate, Long operator) {
        this.attachment = attachment;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        this.status = ConversationStatus.NOT_SUBMITED;
        this.session = session;
        this.delegate = delegate;
        this.disabled = false;
        return this;
    }
    
    /**
     * 
     * @param attachment
     * @param operator
     * @return
     */
    public DelegateCoachingConversation edit(String attachment, Long operator) {
        this.attachment = attachment;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DelegateCoachingConversation edit(Long operator) {
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DelegateCoachingConversation delete(Long operator) {
        this.disabled = true;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DelegateCoachingConversation submit(Long operator) {
        this.status = ConversationStatus.NOT_CONFIRMED;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DelegateCoachingConversation confirm(Long operator) {
        this.status = ConversationStatus.CONFIRMED;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DelegateCoachingConversation reject(Long operator) {
        this.status = ConversationStatus.REJECTED;
        this.lastUpdateTime = new Date();
        this.lastOperator = operator;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the conversationDate
     */
    public Date getConversationDate() {
        return conversationDate;
    }

    /**
     * @return the status
     */
    public ConversationStatus getStatus() {
        return status;
    }

    /**
     * @return the theme
     */
    public String getTheme() {
        return theme;
    }

    /**
     * @return the majorTakeAway
     */
    public String getMajorTakeAway() {
        return majorTakeAway;
    }

    /**
     * @return the nextActionPlan
     */
    public String getNextActionPlan() {
        return nextActionPlan;
    }

    /**
     * @return the attachment
     */
    public String getAttachment() {
        return attachment;
    }

    /**
     * @return the lastUpdateTime
     */
    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the delegate
     */
    public Delegate getDelegate() {
        return delegate;
    }

    /**
     * @return the session
     */
    public Session getSession() {
        return session;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param conversationDate the conversationDate to set
     */
    public void setConversationDate(Date conversationDate) {
        this.conversationDate = conversationDate;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(ConversationStatus status) {
        this.status = status;
    }

    /**
     * @param theme the theme to set
     */
    public void setTheme(String theme) {
        this.theme = theme;
    }

    /**
     * @param majorTakeAway the majorTakeAway to set
     */
    public void setMajorTakeAway(String majorTakeAway) {
        this.majorTakeAway = majorTakeAway;
    }

    /**
     * @param nextActionPlan the nextActionPlan to set
     */
    public void setNextActionPlan(String nextActionPlan) {
        this.nextActionPlan = nextActionPlan;
    }

    /**
     * @param attachment the attachment to set
     */
    public void setAttachment(String attachment) {
        this.attachment = attachment;
    }

    /**
     * @param lastUpdateTime the lastUpdateTime to set
     */
    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param delegate the delegate to set
     */
    public void setDelegate(Delegate delegate) {
        this.delegate = delegate;
    }

    /**
     * @param session the session to set
     */
    public void setSession(Session session) {
        this.session = session;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
